﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Windows.Threading;
using FM.接口;
using Microsoft.Practices.Prism.Mvvm;

namespace FM.Views
{
    /// <summary>
    /// 倒计时窗口.xaml 的交互逻辑
    /// </summary>
    public partial class 倒计时窗口 : Window, IView, I倒计时
    {
        private int _数字 = 10;

        public 倒计时窗口()
        {
            InitializeComponent();
        }

        public double 字体大小
        {
            get { return textBlock1.FontSize; }
            set { textBlock1.FontSize = value; }
        }

        public int 数字
        {
            get { return _数字; }
            set
            {
                _数字 = value;
                textBlock1.Text = _数字.ToString();
            }
        }

        public Brush 字体颜色
        {
            get { return textBlock1.Foreground; }
            set { textBlock1.Foreground = value; }
        }


        public string 标题
        {
            get { return textBlock2.Text; }
            set { textBlock2.Text = value; }
        }

        private DispatcherTimer _timer;
        public void 启动()
        {
            
            this.Show();
            Is启动 = true;
            _timer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(1) };
            _timer.Tick += TimerTick;
            _timer.Start();
        }

        private void TimerTick(object sender, EventArgs e)
        {
            if (--数字 <= 0)
            {
                _timer.Stop();
                Close();
            }
        }

        public bool Is启动 { get; private set; }



        private void Window_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            Close();
        }

        private void Window_MouseDown(object sender, MouseButtonEventArgs e)
        {
            DragMove();
        }



        

    }
}